package com.compass.doctor.ui.home.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.compass.doctor.R
import com.compass.doctor.databinding.LayoutHospitalizationCertificateItemBinding
import com.compass.framework.adapter.BaseBindViewHolder
import com.compass.framework.adapter.BaseRecyclerViewAdapter
import com.compass.framework.glide.setUrlCircle
import com.compass.framework.model.HospitalizedLog
import com.compass.framework.utils.DateUtils
import com.compass.framework.utils.getDrawableResource

/**
 * Description： 住院记录adapter
 * Date:2023/12/21 21:02
 */
class HospitalizedLogAdapter : BaseRecyclerViewAdapter<HospitalizedLog, LayoutHospitalizationCertificateItemBinding>() {
    override fun onBindDefViewHolder(
        holder: BaseBindViewHolder<LayoutHospitalizationCertificateItemBinding>,
        item: HospitalizedLog?,
        position: Int
    ) {
        if (item == null) return
        holder.binding.apply {
            tvSickroom.text = item.inpatientWardName
            tvDiagnosisName.text = item.diagnosisName
            tvDepartmentName.text = item.departmentName
            tvTime.text = "创建时间：${DateUtils.conversionTime(item.createTime,DateUtils.FORMAT_TWO)}"
            tvName.text = item.patientName
            tvAge.text = item.patientAge
            ivHead.setUrlCircle(item.patientAvatar)
            ivSex.background= if (item.patientSex==1) getDrawableResource(R.mipmap.icon_male) else  getDrawableResource(
                R.mipmap.icon_female)
        }
    }

    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): LayoutHospitalizationCertificateItemBinding {
        return LayoutHospitalizationCertificateItemBinding.inflate(layoutInflater, parent, false)
    }
}